From 6f077f141edcc45f2d7467b7c796e62a8f0316f8 Mon Sep 17 00:00:00 2001
From: Sebastien Castiel <sebastien@castiel.me>
Date: Thu, 7 Dec 2023 20:12:40 -0500
Subject: Prevent removing participants with expenses

---
 src/app/groups/[groupId]/edit/page.tsx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'src/app/groups/[groupId]/edit/page.tsx')

diff --git a/src/app/groups/[groupId]/edit/page.tsx b/src/app/groups/[groupId]/edit/page.tsx
index 1fcf225..be1a5a8 100644
--- a/src/app/groups/[groupId]/edit/page.tsx
+++ b/src/app/groups/[groupId]/edit/page.tsx
@@ -1,5 +1,5 @@
 import { GroupForm } from '@/components/group-form'
-import { getGroup, updateGroup } from '@/lib/api'
+import { getGroup, getGroupExpensesParticipants, updateGroup } from '@/lib/api'
 import { groupFormSchema } from '@/lib/schemas'
 import { Metadata } from 'next'
 import { notFound, redirect } from 'next/navigation'
@@ -23,5 +23,12 @@ export default async function EditGroupPage({
     redirect(`/groups/${group.id}`)
   }
 
-  return <GroupForm group={group} onSubmit={updateGroupAction} />
+  const protectedParticipantIds = await getGroupExpensesParticipants(groupId)
+  return (
+    <GroupForm
+      group={group}
+      onSubmit={updateGroupAction}
+      protectedParticipantIds={protectedParticipantIds}
+    />
+  )
 }
-- 
cgit v1.3

